﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _5._18
{
    public partial class Update : Form
    {
        int idd = 0;
        public Update()
        {
            InitializeComponent();
        }
        public Update(int id)
        {
            InitializeComponent();
            idd = id;
        }

        private void Update_Load(object sender, EventArgs e)
        {
            string name = this.tex_name.Text.Trim();
            string type = this.tex_Type.Text.Trim();
            string Amount = this.tex_Amount.Text.Trim();
            string price = this.tex_price.Text.Trim();
            string sql =string.Format( "select * from T_goodsinto where goodsID={0}",idd);
            DataTable table = DBHelper.read(sql);


            name = table.Rows[0]["GoodsName"].ToString();
            type = table.Rows[0]["typename"].ToString();
            Amount = table.Rows[0]["Amount"].ToString();
            price = table.Rows[0]["price"].ToString();

            this.tex_name.Text = name;
            this.tex_Type.Text = type;
            this.tex_Amount.Text = Amount;
            this.tex_price.Text = price;
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string name = this.tex_name.Text.Trim();
            string type = this.tex_Type.Text.Trim();
            string Amount = this.tex_Amount.Text.Trim();
            string price = this.tex_price.Text.Trim();
            string sql = string.Format("Update T_GoodsInto set GoodsName='{0}',Typename='{1}',Amount={2},price={3} where Goodsid={4}", name, type, Amount, price,idd);
            int rs = DBHelper.write(sql);
            if (rs > 0)
            {
                MessageBox.Show("修改成功......");
            }
            else
            {
                MessageBox.Show("修改失败......");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
           
        }
    }
}
